﻿using System;
using System.Linq;
using System.Web;
using System.ServiceModel;
using System.ServiceModel.DomainServices.Hosting;

namespace Jok.Domain.Web
{
    public class DomainServiceHostFactoryEx : DomainServiceHostFactory
    {
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
        {
            return new DomainServiceHost(serviceType, FilterAddresses(baseAddresses));
        }

        private static Uri[] FilterAddresses(Uri[] baseAddresses)
        {
            return baseAddresses.GroupBy(uri => uri.Scheme).SelectMany(uri => uri).ToArray();
        }
    }
}
